<template>
  <div id="app">
    <!-- 正确写法 (用来承载两个页面) -->
    <router-view/>
  </div>
</template>
 
<script>

export default {
  beforeUpdate() {
    this.activeIndex = this.$route.path;
  },
  data()
  {
    
  },
  name: 'App',
  
    created(){
      
    window.addEventListener("beforeunload",()=>{ localStorage.setItem("messageStore",JSON.stringify(this.$store.state))

}),

//在页面加载时读取localStorage里的状态信息

localStorage.getItem("messageStore") &&this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("messageStore"))))

    },
  //   watch: {
  //   $route (to, from) { //to:即将要跳转到的页面   from:即将离开的页面
  //     if (to.path==='/HomePage'&&flag) {
  //       refresh();
       
  
  //     } 
    
  //     console.log(from.path)
  //   }
  // },
  
  // watch: {
  //       $route (to, from) { //to:即将要跳转到的页面   from:即将离开的页面
   
  //       window.location.reload();
  
      
  //      console.log(to.path,from.path)
  //   }
  // },
  methods()
  {
   
  }
}
</script>
 
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 0px;
}
body{
  margin:0;
  padding:0;
  border:0
}

</style>